package com.shopping.www.service;

import com.shopping.www.mapper.MenuMapper;
import com.shopping.www.model.MenuList;
import com.shopping.www.util.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.util.List;


public class MenuService {
    SqlSessionFactory factory= SqlSessionFactoryUtils.getSqlSessionFactory();
    public List<MenuList> showMenu(){
        SqlSession sqlSession=factory.openSession();
        MenuMapper mapper =sqlSession.getMapper(MenuMapper.class);
        List<MenuList> menuLists=mapper.getMenu();
        sqlSession.close();
        return menuLists;
    }
    public List<MenuList> showMenuChildren(){
        SqlSession sqlSession=factory.openSession();
        MenuMapper mapper =sqlSession.getMapper(MenuMapper.class);
        List<MenuList> menuChildrenLists=mapper.getMenuChildren();
        sqlSession.close();
        return menuChildrenLists;
    }
}
